package com.zz.spring6.validator.two;



import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


import javax.validation.ConstraintViolation;
import javax.validation.Validator;
import java.util.Set;

/**
 * 原生的
 */
@Service
public class MyValidator1 {

    @Autowired
    private Validator validator;

    public boolean validatorByUserOne(User1 user){
        Set<ConstraintViolation<User1>> validate = validator.validate(user);
        return validate.isEmpty();
    }
}
